package com.itheima.test;


import com.itheima.bean.Student;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.Test;

import java.io.InputStream;
import java.util.List;


public class StudentTest01 {
    @Test
    public void selectAll() throws Exception {
        InputStream is = Resources.getResourceAsStream("MyBatisConfig.xml");
        SqlSessionFactory build = new SqlSessionFactoryBuilder().build(is);
        SqlSession sqlSession = build.openSession();
        List<Student> list = sqlSession.selectList("StudentMapper.selectAll");
        for (Student student : list) {
            System.out.println(student);
        }
        sqlSession.close();
        is.close();
    }
}
